import java.util.Scanner;

public class test {
    public static int maxNumberOfTwo(int x, int y){
        int temp;
        if(x < y){
            temp = x;
            x = y;
            y = temp;
        }
        return x;
    }
    public static double maxNumberOfThree(double x, double y, double z){
        double temp;
        if(x < y){
            temp = x;
            x = y;
            y = temp;
        }
        if(x < z){
            temp = x;
            x = z;
            z = temp;
        }
        return x;
    }
    public static void main(String[] args) {
        System.out.println("请输入两个数:");

        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        int max_2 = maxNumberOfTwo(x, y);
        System.out.println("较大值为:"+max_2);

        System.out.println("请输入三个小数:");
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        double max_3 = maxNumberOfThree(a, b, c);
        System.out.println("较大值为:"+max_3);
    }
    public static int sum(int x, int y){
        return x + y;
    }
    public static double sum(double x, double y, double z){
        return x + y + z;
    }
    public static void main8(String[] args) {
        System.out.println("请输入两个整数:");

        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int sum_of_int = sum(x, y);
        System.out.println("和为"+sum_of_int);

        System.out.println("请输入三个小数:");
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double c = scanner.nextDouble();
        double sum_of_double = sum(a, b, c);

        System.out.println("和为"+sum_of_double);
    }
    public static int maxNumberOfThree(int x, int y, int z){
        int temp = maxNumberOfTwo(x, y);
        return maxNumberOfTwo(temp, z);
    }

    public static void main7(String[] args){
        System.out.println("请输入两个数:");

        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();

        int max_2 = maxNumberOfTwo(x, y);
        System.out.println("较大值为:"+max_2);

        System.out.println("请输入三个数:");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int max_3 = maxNumberOfThree(a, b, c);
        System.out.println("较大值为:"+max_3);
    }
    public static void main6(String[] args) {
        System.out.println("请输入一个数:");
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int count = 0;
        while(x!=0){
            x&=(x-1);
            count++;
        }
        System.out.println("该数的二进制中1的个数为:"+count);
    }
    public static void main5(String[] args) {
        //求两个数的最大公约数
        System.out.println("请输入两个数:");
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = x % y;
        while(z!=0){
            x = y;
            y = z;
            z = x % y;
        }
        System.out.println("最大公约数为:"+y);
    }
    public static void main4(String[] args){
        //计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值
        double i=1.0;
        double sum=0.0;
        int flag=1;
        for(int j=1;j<=100;j++){
            sum+=i/j*flag;
            flag=-flag;
        }
        System.out.println("1/1-1/2+1/3-1/4+1/5 …… + 1/99-1/100的值为:"+sum);
    }
    public static int judge(int x){
        int i=0;
        if(x<10){
            return (int)Math.pow(x,3);
        }
        else{
            int sum=0;
            do{
                sum+=(int)Math.pow(x%10,3);
                x/=10;
            }while(x>0);
            return sum;
        }
    }
    public static void main3(String[] args){
        //求出0～n之间的所有“水仙花数”并输出。
        System.out.println("请输入n的值:");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println("0~"+n+"之间的水仙花数为:");
        for(int i = 100; i <= n; i++){
            if(judge(i)==i){
                System.out.print(i);
            }
        }
    }
    public static void main2(String[] args){
        //判断素数
        int i;
        System.out.println("请输入要判断的数字:");
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        boolean judge = true;
        if(x == 1){
            System.out.println(x+"不是素数");
        }
        for(i = 2; i <= (int)Math.sqrt(x); i++){
            if(x % i == 0) {
                judge = false;
            }
        }
        if(judge){
            System.out.println(x+"是素数");
        }
        else{
            System.out.println(x+"不是素数");
        }
    }
    public static void main1(String[] args) {
       //编写程序数一下 1到 100 的所有整数中出现多少个数字9
        int count=0;
        for(int i = 1;i <= 100;i++){
            if((i % 9 == 0)||(i / 10 == 9)){
                count++;
            }
        }
        System.out.printf("1到 100 的所有整数中出现了%d个数字9",count);
    }
}
